Skip to content

fix(id-bench): recover stress_gen after interrupted generation - #13211

Merged
dezren39 merged 1 commit into
mainfrom
lane-qw-13181
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-qw-13181

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Closes #13181.

Problem

stress_gen materialized directly into the output root and wrote manifest.json only at the end. A failure mid-generation (the 100x tier is expected to hit resource walls, and the run protocol treats walls as results) stranded the output path: a retry refused because the directory existed without a manifest, with manual deletion as the only recovery. The old code also removed an existing output root based only on the presence of a file named manifest.json, and wrote the manifest non-atomically.

Reproduced on pre-fix main: ID_BENCH_STRESS_HOT_MEMBERS=0 --quick --only stress_gen exits 1 after creating the output directory; the retry exits 1 with stress output root ... exists and holds no stress manifest; refusing to overwrite it.

Change

Generation now materializes into a staging sibling of the output root and publishes by rename. The lifecycle lives in pkgs/id/tests/common/stress_output.rs, included by the bench via #[path] (the existing loadgen pattern) and exercised directly by the new integration suite:

  • Recovery: prepare_stress_output deletes a leftover staging directory only when its ownership marker (.stress-gen-staging.json, written before anything else) parses and names this generator. The completed output root is untouched until publish, so a failed regeneration keeps the last good fixture.
  • Identity, not presence: a previous output root is replaced only after its manifest verifies — type: "stress-manifest" and schema_version: 1. A foreign manifest, a manifest-less partial (the pre-fix stranded shape), or an unmarked staging directory is refused with the cleanup action named, and preserved byte-for-byte.
  • Atomic publication: the manifest is written as a temp file, synced, and renamed inside the staging directory; then the staging directory is renamed into place. The output root only ever holds a complete generation or nothing at all.

bench_stress_gen itself changes only in where it writes (staging instead of the root) and in delegating prepare/publish; the profile line, manifest contents, and generation determinism are unchanged.

Verification

  • New integration suite pkgs/id/tests/stress_gen_recovery.rs (5 tests, laptop, cargo test --test stress_gen_recovery): interrupted generation recovers on retry and the published world restores through WorldCore::restore from its published location; republish replaces a completed generation (journal line count proves no merge); the three refusal shapes each preserve the directory byte-for-byte. All 5 pass (19/19 in the target including the shared common module tests).
  • Existing consumer of common unaffected: cargo test --test loadgen_determinism 16/16.
  • End-to-end with the rebuilt bench binary, the issue's own reproduction: fail with HOT_MEMBERS=0 → exit 1, no output root created, staging leftover carries the marker; retry with the same bad config → staging recovered, same real error (not the old refusal); retry fixed → success, profile line identical in shape with the same quick-tier hot_state_hash=8ef2ffc8a61f687b recorded when the profile landed in feat(id): seeded stress-world generator in world_bench (#13083) #13163 (determinism preserved); regeneration over the completed fixture → success; foreign-manifest directory → refusal with contents intact. --quick --only guest_replay unaffected.
  • rustfmt applied; clippy over the bench + new test target reports no warnings in the touched files.
  • Remote dispatch attempted per the dispatch-first rule (run 45160224820): the container's command step failed before any test ran — the known fleet-build container toolchain gap (fix(fleet): fleet-command Run step lacks the toolchain on PATH — dispatched cargo commands fail 127 #13170/fleet: fleet-command dispatch container cannot run nix develop out of the box (experimental features, nixbld group, homeless-shelter purity) #13159 family, flag-held), an environment failure, not a test result. The laptop runs above are the verifying route.
{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T10:59:39Z",
    "session_id": null,
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/wt-lane-qw-13181",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/wt-lane-qw-13181",
      "repo": "developing-today/code",
      "branch": "lane-qw-13181",
      "sha": "cea664de6776bbba4794b9a64c066b3cf4efe7a4"
    },
    "auth_subject": "oc-code-07",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

stress_gen materialized directly into the output root and wrote
manifest.json only at the end, so any failure mid-generation (the
100x tier is expected to hit resource walls) stranded the output
path: a retry refused because the directory existed without a
manifest, and the only recovery was manual deletion. The old code
also removed an existing output root based only on the presence of
a file named manifest.json, and wrote the manifest non-atomically.

Generation now materializes into a staging sibling carrying an
ownership marker, and publishes by rename:

- prepare recovers a leftover staging directory only when its
  marker verifies it as this generator's, and refuses unverified
  content at either path with the cleanup action named;
- a completed output root is replaced only after its manifest
  verifies (type "stress-manifest", schema_version 1), and only
  at publish time, so a failed regeneration keeps the last good
  fixture;
- the manifest is written atomically (temp file, sync, rename)
  inside the staging directory before the publish rename, so the
  output root only ever holds a complete generation or nothing.

The lifecycle lives in tests/common/stress_output.rs, included by
the bench via #[path] (the loadgen pattern) and exercised by the
new tests/stress_gen_recovery.rs integration suite: interrupted
generation recovering on retry with a restorable published world,
republish replacing a completed generation, and the three refusal
shapes (foreign manifest, manifest-less partial, unmarked staging)
each preserving the directory byte-for-byte.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3eeacce4-cc9d-4676-b553-184bff5b1c6f
Commits

Reviewing files that changed from the base of the PR and between 0ca8ed6 and cea664d.

Files selected for processing: 4

  • pkgs/id/benches/world_bench.rs
  • pkgs/id/tests/common/mod.rs
  • pkgs/id/tests/common/stress_output.rs
  • pkgs/id/tests/stress_gen_recovery.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T11:01:01.255594Z cea664d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 095714b into main Nov 23, 2026
2 checks passed
@dezren39
dezren39 deleted the lane-qw-13181 branch November 23, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(id-bench): recover stress_gen after interrupted generation

1 participant